import numpy
import requests
import csv

# 请求网页
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
    'Referer': 'https://www.cingta.com/school/ser',
    'Cookie': 'UM_distinctid=17a09083cfdcc-0ba4d1e2ecf12f-2363163-144000-17a09083cfe156; CNZZDATA1254581267=1801598425-1623647277-%7C1623647277'
}

url = 'https://www.cingta.com/school/api/name_uni_list/'

res =  requests.post(url=url, headers=headers)
# 权限认证
a = []
for i in range(0,50):
     a1 = res.json()['data']['list'][i]
     a += a1.values()
# print(a)
list = numpy.array(a).reshape(50,-1)
print(list)
# print(res.json()['data']['list'])




f = open('pachong.csv', 'w', encoding='utf-8', newline='' "")
csv_writer = csv.writer(f)
csv_writer.writerow(["lined", "code", "schoolname", "province", "city", "department", "level", "type", "link"])
for i in list:
    csv_writer.writerow(i)
csv_writer.writerow(list)
f.close()


